<?php
// @formatter:off
/**
 * @file WCTool.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-08-20 00:23:06 +0000 (Tue, 20 Aug 2013) $
 *
 * $Id: WCTool.php 102 2013-08-20 00:23:06Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0.0.1/includes/WCTool.php $
 */
// @formatter:on

/**
 * @abstract
 * @class WCTool This class represents in a general way something similar to cron
 * tools, but these run on demand.
 * Children of this class are wcomix extra tools and the may perform many tasks
 * considered to be "out of the box". This extra tools may repair some broken
 * stuff or perform really important tasks that cannot be placed on web interface.
 */
class WCTool {
	/**
	 * @var WCConnection Database pointer shortcut.
	 */
	protected $_db = null;
	/**
	 * @var string Database tables' prefix shortcut.
	 */
	protected $_dbprefix = "";
	/**
	 * @var boolean This flag indicates the list of options and their
	 * configuration are already loaded.
	 */
	protected $_optionsLoaded = false;
	/**
	 * Class constructor.
	 */
	public function __construct() {
		//
		// Loading global pointers.
		global $wcDatabaseAccess;
		//
		// Loading shortcuts.
		// @{
		$this->_db = WCConnection::Instance();
		$this->_dbprefix = $wcDatabaseAccess["prefix"];
		// @}
		//
		// Loading options list.
		$this->loadOptions();
	}
	//
	// Public methods.
	/**
	 * This method is called by 'WCToolsManager' when a tool must perform its
	 * tasks.
	 *
	 * @param string $spacer This s a prefix to add on each prompted line.
	 */
	public function run($spacer = "") {
		//
		// This method must be implemented by a sub-class, otherwise it
		// aborts.
		die(__CLASS__."::".__FUNCTION__."() Subclass Resposabillity\n");
	}
	/**
	 * This method is called by 'WCToolsManager' when a tool must prompt its
	 * help text.
	 *
	 * @param string $spacer This s a prefix to add on each prompted line.
	 */
	public function showHelp($spacer = "") {
		//
		// This method must be implemented by a sub-class, otherwise it
		// aborts.
		die(__CLASS__."::".__FUNCTION__."() Subclass Resposabillity\n");
	}
	//
	// Protected methods.
	/**
	 * This method is called by 'WCToolsManager' when a tool must load and
	 * configure its options and parameters.
	 * It must also modify variable '$this->_optionsLoaded'.
	 */
	protected function loadOptions() {
		//
		// This method must be implemented by a sub-class, otherwise it
		// aborts.
		die(__CLASS__."::".__FUNCTION__."() Subclass Resposabillity\n");
	}
}
?>